extends CardState

	
func on_mouse_exited():
	transition_requested.emit(self, State.STATE_IN_HAND)
		
func on_card_select() -> void:
	
	if card_view.card.is_attack_card() and CardManager.round_data.cant_attack:
		return
	if get_parent().trophy_mode:
		transition_requested.emit(self, State.STATE_TROPHY_SELECT)
		return
	elif CardManager.round_data.card_switch_select_mode:
		transition_requested.emit(self, State.STATE_CARD_SELECTED)
		return
	else:
		if(CardManager.avail_point >= card_view.card.point):
			transition_requested.emit(self, State.STATE_PICKUP)

func enter() -> void:
	if get_parent().trophy_mode:
		card_view.border_panel.set("theme_override_styles/panel", card_view.PICKUP_STYLEBOX)
	elif CardManager.round_data.card_switch_select_mode :
		card_view.border_panel.set("theme_override_styles/panel", card_view.PICKUP_STYLEBOX)
		card_view.card_container.organize_cards.emit(false, false, true, card_view)
	else:	
		if(CardManager.avail_point >= card_view.card.point):
			card_view.card_container.organize_cards.emit(false, false, true, card_view)
			card_view.border_panel.set("theme_override_styles/panel", card_view.HOVER_STYLEBOX)
		else:
			card_view.card_container.organize_cards.emit(false, false, false, null)
		
	
func exit() -> void:
	pass
	
func update_transform(_in_hand_rotation, _in_hand_position , in_hand_hover_position):	
	card_view.z_index = 100

	if card_view.tween:
		card_view.tween.kill() # 终止之前的补间动画。
	card_view.tween = card_view.create_tween()
	
	var tween : Tween = card_view.tween
	tween.set_parallel()
	tween.tween_property(card_view, "rotation", 0, 0.1)
	tween.tween_property(card_view, "position", in_hand_hover_position, 0.1)
	tween.play()
